// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class userInfo extends cc.Component {
    init(info, position){
        cc.find("Canvas").addChild(this.node)
        this.node.getChildByName("name").getComponent(cc.Label).string = info.name
        this.node.getChildByName("money").getChildByName("value").getComponent(cc.Label).string = info.value
        switch(position){
            case 'center':
                this.node.x=70;this.node.y=115;break;
            case 'left':
                this.node.x=70;this.node.y=380;break
            case 'right':
                this.node.x=890;this.node.y=380;break
        }
        this.node.x-=cc.view.getVisibleSize().width/2
        this.node.y-=cc.view.getVisibleSize().height/2
    }
    showHat(){
        this.node.getChildByName("dzhat").active = true
    }
}
